/**
 * 菜单详情对话框
 */
var RechargeListDlg = {
    RechargeListDlgData: {},
    ztreeInstance: null,
    validateFields: {
    	confirm_transfer_time: {
            validators: {
                notEmpty: {
                    message: '产品名称不能为空'
                }
            }
        },
        actual_amount: {
            validators: {
                notEmpty: {
                    message: '产品代码不能为空'
                }
            }
        }
    }
};

/**
 * 清除数据
 */
RechargeListDlg.clearData = function () {
    this.RechargeListDlgData = {};
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
RechargeListDlg.set = function (key, val) {
    if(key!="status"){
        this.RechargeListDlgData[key] = (typeof value == "undefined") ? $("#" + key).val() : value;
    }else{
        this.RechargeListDlgData[key] = (typeof value == "undefined") ? $("input[name='radio']:checked").val() :value;
    }
    return this;
}

/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
RechargeListDlg.get = function (key) {
    return $("#" + key).val();
}

/**
 * 关闭此对话框
 */
RechargeListDlg.close = function () {
    parent.layer.close(window.parent.RechargeList.layerIndex);
}

/**
 * 收集数据
 */
RechargeListDlg.collectData = function () {
    this.set('recharge_no').set('actual_amount').set('confirm_transfer_time').set('remarks');
  
    var str = this.RechargeListDlgData["confirm_transfer_time"];
    if(str!=""){
    var date = new Date(str);
    date = format(date ,"yyyy-MM-dd hh:mm:ss");
    this.RechargeListDlgData["confirm_transfer_time"]=date;//.getTime();
    var remarks = this.RechargeListDlgData["remarks"];
    var actual_amount = this.RechargeListDlgData["actual_amount"];
    var amount = $("#amount").text();
    if(actual_amount==amount){
    	this.RechargeListDlgData["remarks"]=null;
    }
    
    }

}

format=function(date,format){
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
    return currentdate;
}
RechargeListDlg.validate = function () {
	if(this.RechargeListDlgData["recharge_no"]==""){
		Feng.error("记录号不能为空！");
		return false;
	}
	if(this.RechargeListDlgData["confirm_transfer_time"]==""){
		Feng.error("时间不能为空！");
		return false;
	}
	if(this.RechargeListDlgData["actual_amount"]==""){
		Feng.error("金额不能为空！");
		return false;
	}
	
	return true;
}
/**
 * 提交修改
 */
RechargeListDlg.editSubmit = function () {

    this.clearData();
    this.collectData();
    var req=this.validate();
    if(req){
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/rechargeList/update", 
    		function (data) {
    	if(data["code"]==2){
    		Feng.error(data["message"] + "!");
    	}else{
        Feng.success("修改成功!");
        window.parent.RechargeList.table.refresh();
        RechargeListDlg.close();
    	}
    }, function (data) {
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    })
    ajax.set(this.RechargeListDlgData);
    ajax.start();
    }
}




;
